<template>
  <view>
    <el-table v-loading="loading" :data="tableData">
      <!-- <el-table-column type="selection" width="55" align="center" /> -->
      <el-table-column label="文件编号" align="center" prop="id" />
      <el-table-column label="文件名称" align="center" prop="fileName" />
      <el-table-column label="文件类型" align="center" prop="extName" />
      <el-table-column label="分类" align="center" prop="fileType" />
      <el-table-column label="状态" align="center" prop="status">
        <template #default="scope">
          <el-switch :disabled="!isAdmin" v-model="scope.row.status" :active-value="1" :inactive-value="0" @change="handleStatusChange(scope.row)"></el-switch>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" align="center" prop="createdTime" width="180">
        <template #default="scope">
          <span>{{ parseTime(scope.row.createdTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template #default="scope">
          <!-- <el-button type="text" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['cms:category:update']">修改</el-button> -->
          <el-button type="text" icon="Edit" @click="handleEdit(scope.row)" v-hasPermi="['cms:category:delete']">编辑</el-button>
          <el-button type="text" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['cms:category:delete']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </view>
</template>
<script setup>
import userStore from "@/store/modules/user";
const isAdmin = ref(userStore().isAdmin);
const { proxy } = getCurrentInstance();

const emit = defineEmits(["delete","edit"]);
const props = defineProps({
  loading: {
    type: Boolean,
  },
  tableData: {
    type: Array,
  },
});
const sys_normal_disable = ref([
  {
    value: 1,
    label: "启用",
  },
  {
    value: 0,
    label: "未启用",
  },
]);
// 删除相关数据
function handleDelete(row){
  emit('delete',row);
}
// 编辑相关数据
function handleEdit(row){
  emit('edit',row)
}
</script>
